package com.thirteenClassicsServer.controller;

//import com.baidubce.services.bos.BosClientConfiguration;

import javax.annotation.Resource;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.w3c.dom.Document;

import com.thirteenClassics.result.Result;
import com.thirteenClassicsServer.mapper.BookMapper;
import com.thirteenClassicsServer.mapper.CatalogBookMapper;
import com.thirteenClassicsServer.mapper.CatalogMapper;
import com.thirteenClassicsServer.mapper.SentenceJdbMapper;
import com.thirteenClassicsServer.mapper.SentenceMapper;
import com.thirteenClassicsServer.service.IBookService;
import com.thirteenClassicsServer.service.ICatalogBookService;
import com.thirteenClassicsServer.service.IPictureService;
import com.thirteenClassicsServer.service.impl.FileServiceImpl;
import com.thirteenClassicsServer.service.impl.XmlParseService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/test2")
public class Test2Controller {
    private static final String ACCESS_KEY_ID = "your-access-key-id";
    private static final String SECRET_ACCESS_KEY = "your-secret-access-key";
    private static final String ENDPOINT = "your-bos-endpoint";
    private static final String BUCKET_NAME = "your-bucket-name";
    private final Document document = null;
    @Resource
    private CatalogBookMapper catalogBookMapper;
    @Resource
    private CatalogMapper catalogMapper;
    @Resource
    private BookMapper bookMapper;
    @Resource
    private SentenceMapper sentenceMapper;
    @Resource
    private SentenceJdbMapper sentenceJdbMapper;
    @Resource
    private IBookService bookService;
    @Resource
    private IPictureService pictureService;
    @Resource
    private ICatalogBookService catalogBookService;
    @Resource
    private FileServiceImpl fileService;
    @Resource
    private XmlParseService xmlParseService;
    @Resource
    private TestController testController;

    @GetMapping("/cleanCacheTest")
    public Result cacheTest(@RequestParam("a") int a) {
        cleanCache(a);


        return Result.success();
    }

    @GetMapping("/queryCacheTest")
    public Result queryCacheTest(@RequestParam("a") int a) {
        putCache(a);


        return Result.success();
    }

    @Cacheable(value = "value", key = "#a")
    public Integer putCache(int a) {
        System.out.println(a + System.currentTimeMillis());
        return a * a * a;
    }


    @CacheEvict(value = "value", key = "#a")
    public void cleanCache(int a) {
        testController.flashCache(a);
    }

}